//
//  ChatListTitleView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/9/7.
//

import SwiftUI

struct ChatListTitleView: View {
    @State var bean: ChatListTitleBean
    
    var body: some View {
        VStack(alignment: .leading, spacing: 2) {
            HStack(spacing : 4){
                Text(bean.title)
                    .font(.system(size: 16, weight: .medium))
                    .foregroundColor(.bgNormalText)
                Text(String(bean.count))
                    .font(.system(size: 12, weight: .medium))
                    .foregroundColor(Color.hex("#999999"))
                    .frame(width: 18,height: 18)
                    .background(Color.hex("#dbdbdb"))
                    .clipShape(.circle)
                // 添加自动缩放设置
                    .minimumScaleFactor(0.5) // 允许最小缩放到原始字体大小的50%
                    .lineLimit(1) // 限制文本只显示一行，确保缩放效果正常
            }
            if (bean.description).isEmpty == false {
                Text(bean.description)
                    .font(.system(size: 12, weight: .medium))
                    .foregroundColor(.bgNormalText4)
            }
        }.frame(maxWidth: .infinity,alignment: .leading)  // 关键：让VStack宽度充满父容器
            .padding(.top,20)
    }
}

#Preview {
    ChatListTitleView(bean: ChatListTitleBean(title: "已选择心灵角色", description: "已选定的角色才能触发日记回复，来电，来信", count: 5))
}
